package com.ogawa.base.utils;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtils {
    
    private static String PatternDate = "yyyy-MM-dd";

    private static String PatternTime = "yyyy-MM-dd HH:mm:ss:SSS";


    public static String printDateStr(String y, String m,String d){
        return y + "-" +m + "-" +d;
    }

    //年月日转13位
    public static long ydmTo13Long(String y, String m,String d){
        String date = y + "-" +m + "-" +d + " 00:00:00:000";
        return getStringToDate(date);
    }


    /*
    时间戳转换成字符串
     */
    public static String getDateToString(long time) {
        try{
            Date d = new Date(time);
            SimpleDateFormat sf = new SimpleDateFormat(PatternDate);
            return sf.format(d);
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
/**
 * 将字符串转为时间戳
 */
public static long getStringToDate(String time) {
    SimpleDateFormat sf = new SimpleDateFormat(PatternTime);
    Date date = new Date();
    try{
            date = sf.parse(time);
        } catch(ParseException e) {
            e.printStackTrace();
        }
    return date.getTime();
}


}
